using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace MTRC.ODMS.Web.SOM.CodeSetup
{
    /// <summary>
    /// Author:SQB
    /// </summary>
    public partial class WorkCategoryList : BasePage_SOM
    {
        #region MenuID

        protected override string MenuID
        {
            get
            {
                return "M140805";
            }
        }

        #endregion

        #region Page Init And Load

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.ChangeLanguage += new ChangeLanguageEventHandler(SetLanguage_Click);
        }

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // add by dylan 20151030 for u275.1 
                this.grvData.PageSize = this.GridViewPageDefaultSize();
                SetLanguage();
            }
        }

        private void SetLanguage()
        {
            this.lbl_CodeSetupTitle.Text = this.GetLabel("SOM_CodeSetupWorkCategoryList");
            this.lblCat.Text = this.GetLabel("SOM_WorkCategory",true);
            this.chkVoid.Text = this.GetLabel("SOM_Voided");
            this.btnSearch.Text = this.GetLabel("COM_Search");
            this.btnAddNew.Text = this.GetLabel("SOM_AddNewAssetLoanItem");
            this.lblDisplay.Text = this.GetLabel("COM_Show", true);
            BindData();
        }

        void SetLanguage_Click(object sender, EventArgs e)
        {
            SetLanguage();
        }

        private void BindData()
        {
            DataTable dt = MTRC.ODMS.DAL.SOM.CodeSetup.CDAdmRegCategory.GetWorkCategory(this.LangCode,this.txtCat.Text.Trim(),this.chkVoid.Checked);
            this.grvData.DataSource = dt.DefaultView;
            this.grvData.DataBind();
        }

        protected void grvData_NeedDataBind()
        {
            BindData();
        }

        protected void grvData_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ((HyperLink)e.Row.Cells[6].FindControl("hypEdit")).NavigateUrl = "WorkCategoryEntry.aspx?AdmRegCategoryID=" + this.grvData.DataKeys[e.Row.RowIndex]["AdmRegCategoryID"].ToString();
                ((HyperLink)e.Row.Cells[6].FindControl("hypEdit")).ToolTip = this.GetLabel("SOM_WorkCategoryEntry");
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindData();
        }

        protected void btnAddNew_Click(object sender, EventArgs e)
        {
            this.Response.Redirect("WorkCategoryEntry.aspx");
        }
    }
}
